<%= form_for [:admin, @coupon], html: { class: "card" } do |f| %>
  <div class="card-body">
    <h3 class="card-title">
      <%= @coupon.new_record? ? "新增优惠券" : "修改优惠券" %>
    </h3>
    <div class="row">
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">优惠券名字</label>
          <%= f.text_field :name, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">优惠金额</label>
          <%= f.number_field :money, class: "form-control", min: "1" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">满金额</label>
          <%= f.number_field :full_money, class: "form-control", min: "0" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">分类</label>
          <%= f.select :shop_category_id, ShopCategory.where(level: 1).select('id, name').map{ |c| [c.name, c.id] }, { include_blank: '请选择分类' }, { class: 'form-control select' } %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">开始时间</label>
          <%= f.date_field :start_at, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">结束时间</label>
          <%= f.date_field :end_at, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">状态</label>
          <%= f.select :state, Coupon.states.keys.map {|state| [I18n.t("coupon.state.#{state.titleize.downcase}"), state]}, {}, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-12">
        <div class="form-group">
          <label class="form-label">优惠券说明</label>
          <%= f.text_field :remark, class: "form-control" %>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer text-right">
    <%= f.submit "保 存", class: "btn btn-primary" %>
  </div>
<% end %>